package com.cn.ccp.action.task;

import java.util.List;

import org.apache.log4j.Logger;

import com.cn.ccp.action.BaseAction;
import com.cn.ccp.bean.CourseBean;
import com.cn.ccp.bean.RoleBean;
import com.cn.ccp.bean.UserBean;
import com.cn.ccp.util.CCPContants;

/**
 * 老师当前任务
 * @author renyongcheng
 *
 */
public class TaskTeachAction extends BaseAction {
	private Logger log = Logger.getLogger(TaskTeachAction.class);
 
	private int onlineCourses;//在线辅助教学课程数量
	private int editingCourse;//正在编辑的课程数量
	private int releaseApprovalCourse;//正在审批的课程数量
	private int releaseCourse;//正在等待发布的课程数量
	private boolean realseProve;//具有发布权限
	private boolean releaseApprovalProve;//具有审批权限
	private int waitRealseNum;//等待当前用户发布的课程数量
	private int waitReleaseApprovalNum;//等待当前用户审批的课程数量
	private int downNum;//下架课程数量 
	
	public TaskTeachAction(){
		UserBean userBean = CCPContants.getUserBean();
		List<CourseBean> list = getCourseService().onlineTeach(String.valueOf(userBean.getId()), 0, 10000); 
		onlineCourses = list.size();
		List<String> strList = getCourseService().getCourseStatusByUserId(userBean.getId());
		for(String s : strList){
			if("1".equalsIgnoreCase(s))
				editingCourse++;
			else if("2".equalsIgnoreCase(s))
				releaseApprovalCourse++;
			else  if("4".equalsIgnoreCase(s))
				releaseCourse++;
		}
		log.info("----onlineCourses = "+onlineCourses);
		log.info("----editingCourse = "+editingCourse);
		log.info("----releaseApprovalCourse = "+releaseApprovalCourse);
		log.info("----releaseCourse = "+releaseCourse);
		
		List<RoleBean> roleList = getRoleService().getUserRoleList(userBean.getId());
		for(RoleBean b : roleList){
			if(b.getId() == 6){//有教研组长权限的才有此提示。
				releaseApprovalProve = true;
				waitReleaseApprovalNum = getCourseService().getCountReleaseApproval();
			}else if(b.getId() == 4){//有业务管理员权限的才有此提示。
				realseProve = true;
				waitRealseNum = getCourseService().getCountReleaseForUser();
				downNum = getCourseService().getCountDownForUser();
			}
		}
		
	}


	public int getOnlineCourses() {
		return onlineCourses;
	}


	public void setOnlineCourses(int onlineCourses) {
		this.onlineCourses = onlineCourses;
	}


	public int getEditingCourse() {
		return editingCourse;
	}


	public void setEditingCourse(int editingCourse) {
		this.editingCourse = editingCourse;
	}


	public int getReleaseApprovalCourse() {
		return releaseApprovalCourse;
	}


	public void setReleaseApprovalCourse(int releaseApprovalCourse) {
		this.releaseApprovalCourse = releaseApprovalCourse;
	}


	public int getReleaseCourse() {
		return releaseCourse;
	}


	public void setReleaseCourse(int releaseCourse) {
		this.releaseCourse = releaseCourse;
	}


	public boolean isRealseProve() {
		return realseProve;
	}


	public void setRealseProve(boolean realseProve) {
		this.realseProve = realseProve;
	}


	public boolean isReleaseApprovalProve() {
		return releaseApprovalProve;
	}


	public void setReleaseApprovalProve(boolean releaseApprovalProve) {
		this.releaseApprovalProve = releaseApprovalProve;
	}


	public int getWaitRealseNum() {
		return waitRealseNum;
	}


	public void setWaitRealseNum(int waitRealseNum) {
		this.waitRealseNum = waitRealseNum;
	}


	public int getWaitReleaseApprovalNum() {
		return waitReleaseApprovalNum;
	}


	public void setWaitReleaseApprovalNum(int waitReleaseApprovalNum) {
		this.waitReleaseApprovalNum = waitReleaseApprovalNum;
	}


	public int getDownNum() {
		return downNum;
	}


	public void setDownNum(int downNum) {
		this.downNum = downNum;
	}
	
	 
	
	 
	
}
